//
//  LicensendincomeViewController.m
//  Doctors
//
//  Created by 王森 on 16/4/19.
//  Copyright © 2016年 王森. All rights reserved.
//

#import "LicensendincomeViewController.h"
#import "LicensedInComeTableViewCell.h"
@interface LicensendincomeViewController ()

@end

@implementation LicensendincomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addLeftBackBtn:nil];
    self.title=@"我的收入";
    [self initWithTableViewNib:@"LicensedInComeTableViewCell" didSelectCellBlock:^(NSIndexPath *indexPath) {
        
    }];
    
    [self requestData];
    
    __weak typeof(self)weakSelf=self;
    
    [self setTableHeaderRefresh:^{
        [weakSelf.dataArray removeAllObjects];
        [weakSelf requestData];
    }];
    
    
    
    
    // Do any additional setup after loading the view.
}

-(void)requestData
{
    [self addProgressHUD];
    
    
    [self requestApiWithUrl:@"/artisan/getMedicalIncome" dictionary:@{@"artisanId":[self getArtisanId]} isCache:NO  success:^(id responseObject) {
        
        [self removeStatuslable];
        
        NSLog(@"%@",responseObject);
        
//        for (int i=0; i<3; i++) {
//            
//            NSDictionary *dic=@{};
//            
//        }
            NSDictionary *dic=@{@"price":StringWithFormat(responseObject[@"amount"]),@"title":@"治疗费总收入(元)"};
            [self.dataArray addObject:dic ];
        
            
        NSDictionary *dic2=@{@"price":StringWithFormat(responseObject[@"herbalAmt"]),@"title":@"草药费总收入(元)"};
        [self.dataArray addObject:dic2];

            NSDictionary *dic3=@{@"price":StringWithFormat(responseObject[@"otherAmt"]),@"title":@"其他收入(元)"};
            [self.dataArray addObject:dic3];

        [self.tableview reloadData];
        
        
        
    } faild:^(NSError *error) {
        
    }];
    

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //    __weak typeof(self)weakSelf=self;
    //
    //    OrderModel *model=self.dataArray[indexPath.row];
    
    LicensedInComeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LicensedInComeTableViewCell" forIndexPath:indexPath];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.shouRu.text=self.dataArray[indexPath.row][@"title"];

    cell.price.text=self.dataArray[indexPath.row][@"price"];
    
    
    
//    [cell cellFuzhi:self.dataArray[indexPath.row]];
//
//    __weak typeof(self)weakSef=self;
//    
//    [cell setReRqquest:^{
//        [weakSef requestData:@"1"];
//        
//    }];
//    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 123;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
